package cn.imnaer.service.rest.view.model;

import cn.imnaer.service.persistence.model.*;
import cn.imnaer.service.rpc.enums.EnumFriendCircleType;

/**
 * 部落
 * Created by Administrator on 2015/7/31.
 */
public class TribalCircleResponse {
    private String tribalId;
    private String tribalCircleType;
    private String itemId;
    private String title;
    private String image;
    private Boolean isStar;
    private Boolean isAdditions;
    private String userId;
    private String userName;
    private String photoType;
    private String placeType;
    private String placeId;
    private String placeName;
    private int placeCount;
    private int dayCount;
    private int supportCount = 0;
    private long createTime;


    public TribalCircleResponse parse(TribalCircle tribalCircle) {
        this.tribalId = tribalCircle.getTribalId();
        this.itemId = tribalCircle.getItemId();
        this.image = tribalCircle.getImage();
        this.userId = tribalCircle.getUserId();
        this.userName = tribalCircle.getUserName();
        this.isStar = tribalCircle.getIsStar();
        this.isAdditions = tribalCircle.getIsAdditions();
        this.createTime = tribalCircle.getCreateTime();
        return this;
    }

    public TribalCircleResponse parse(SharePhoto sharePhoto) {
        this.title = sharePhoto.getSharePhotoName();
        this.photoType = sharePhoto.getType();
        this.placeId = sharePhoto.getPlaceId();
        this.placeName = sharePhoto.getPlaceName();
        this.placeType = sharePhoto.getPlaceType();
        return this;
    }

    public TribalCircleResponse parse(TravelNote travelNote) {
        this.title = travelNote.getTravelNoteName();
        this.placeCount = travelNote.getPlaceCount();
        this.dayCount = travelNote.getDayCount();
        return this;
    }

    public void loadSupportCount(TribalCircle tribalCircle, SharePhoto sharePhoto) {
        int supportCount = 0;
        for (TribalMessage tribalMessage : sharePhoto.getTribalMessages()) {
            if(tribalMessage.getTribalId().equals(tribalCircle.getTribalId())) {
                supportCount += tribalMessage.getSupportUsers().size();
            }
        }
        this.setSupportCount(supportCount);
    }

    public void loadSupportCount(TribalCircle tribalCircle, TravelNote travelNote) {
        int supportCount = 0;
        for (TravelNotePhoto travelNotePhoto : travelNote.getTravelNotePhotos()) {
            for (TribalMessage tribalMessage : travelNotePhoto.getTribalMessages()) {
                if(tribalMessage.getTribalId().equals(tribalCircle.getTribalId())) {
                    supportCount += tribalMessage.getSupportUsers().size();
                }
            }
        }
        this.setSupportCount(supportCount);
    }



    public String getTribalId() {
        return tribalId;
    }

    public void setTribalId(String tribalId) {
        this.tribalId = tribalId;
    }

    public String getTribalCircleType() {
        return tribalCircleType;
    }

    public void setTribalCircleType(String tribalCircleType) {
        this.tribalCircleType = tribalCircleType;
    }

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Boolean getIsStar() {
        return isStar;
    }

    public void setIsStar(Boolean isStar) {
        this.isStar = isStar;
    }

    public Boolean getIsAdditions() {
        return isAdditions;
    }

    public void setIsAdditions(Boolean isAdditions) {
        this.isAdditions = isAdditions;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPhotoType() {
        return photoType;
    }

    public void setPhotoType(String photoType) {
        this.photoType = photoType;
    }

    public int getPlaceCount() {
        return placeCount;
    }

    public void setPlaceCount(int placeCount) {
        this.placeCount = placeCount;
    }

    public int getDayCount() {
        return dayCount;
    }

    public void setDayCount(int dayCount) {
        this.dayCount = dayCount;
    }

    public int getSupportCount() {
        return supportCount;
    }

    public void setSupportCount(int supportCount) {
        this.supportCount = supportCount;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }


    public String getPlaceType() {
        return placeType;
    }

    public void setPlaceType(String placeType) {
        this.placeType = placeType;
    }

    public String getPlaceId() {
        return placeId;
    }

    public void setPlaceId(String placeId) {
        this.placeId = placeId;
    }

    public String getPlaceName() {
        return placeName;
    }

    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }
}
